'use strict';

const Controller = require('egg').Controller;

class LoginController extends Controller {
  async index() {
    const { ctx } = this;
    console.log(ctx.request.body)
    var db =  this.app.mongodb;
    var {username,pass} = ctx.request.body
    var res =await db.collection("name").find({username,pass}).toArray();
    console.log(res);
    if(res.length){
        ctx.body = {
            code:200,
            msg:"登录成功"}
    }else{
        ctx.body = {
            code:400,
            msg:"登录失败，用户名或密码错误"
        }
    }
  }
}

module.exports = LoginController;
